const moduleAlias = require('module-alias/register.js')
global.to = function(promise) {
    if (!promise) {
        return new Promise(resolve =>
            resolve([new Error("to requires promise as input param, !promise is true")])
        )
    }
    if (!(promise instanceof Promise)) {
        return new Promise(resolve =>
            resolve([new Error("to requires promise as input param, promise isn't Promise type")])
        )
    }

    return promise
            .then(function(){return [null, ...arguments]})
            .catch(err => [err])
}

global.ERROR = {
    OK: 0,
    NO_ENTRY: 1,
    CONFLICT: 2,
    FAILURE: 3,
}

require('./cli.js')(process.argv)
